package com.ilongsay.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 *@Author ilongsay
 *@Email ilongsay@163.com
 *@CreateTime 2018-07-31 22:25
 *@Description 监听器
*/
public class ServerStartupListener implements ServletContextListener {
    /**
     *@Author ilongsay
     *@Email ilongsay@163.com
     *@CreateTime 2018-07-31 22:26
     *@Description 这个方法在web应用初始化的时候会被监听到,将web应用的名称保存在application域范围中
    */
    public void contextInitialized(ServletContextEvent sce) {
        ServletContext application = sce.getServletContext();
        String path = application.getContextPath();
        application.setAttribute("PATH",path);
    }

    public void contextDestroyed(ServletContextEvent sce) {

    }
}
